package com.titaniume.activitiweb;

import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricTaskInstance;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 *@program: activiti7_workflow
 *@description: 历史任务
 *@author: renfei.huang
 *@create: 2021-11-09 16:14
 */
@SpringBootTest
public class Part5_HistoricTaskInstance {

    @Autowired
    private HistoryService historyService;

    //act_hi_procinst,act_hi_identitylink,act_hi_actinst,act_hi_taskinst 变化
    //根据用户名查询历史记录
    @Test
    public  void HistoricTaskInstanceByUser(){

        List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
                .orderByHistoricTaskInstanceEndTime().asc()
                .taskAssignee("bajie")
                .list();
        for (HistoricTaskInstance hi : list) {
            System.out.println(" Id:" + hi.getId());
            System.out.println(" ProcessInstanceId:" + hi.getProcessInstanceId());
            System.out.println(" Name:" + hi.getName());
        }

    }


    //根据流程实例Id查询历史
    @Test
    public  void HistoricTaskInstancePiID(){

        List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
                .orderByHistoricTaskInstanceEndTime().asc()
                .processInstanceId("f48842be-4810-11ec-a783-8cec4b5c0c44")
                .list();
        for (HistoricTaskInstance hi : list) {
            System.out.println(" Id:" + hi.getId());
            System.out.println(" ProcessInstanceId:" + hi.getProcessInstanceId());
            System.out.println(" Name:" + hi.getName());
        }
    }
}
